package com.sense.cloud.sms.web.controller;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class TestController {
	@RequestMapping(value = "valid")
	@ResponseBody
	public Object valid(@Valid TUser user, BindingResult result) {
		if (result.hasErrors())
			return result.getFieldErrors().get(0).getDefaultMessage();
		return user;
	}
}
